﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CO2FixCalibration
{
    class DirectoryStructure
    {
        string outputdir;

        public string SubDir(int i)
        {
            string subdir = outputdir +"\\" + i +"\\";
            if(System.IO.Directory.Exists(subdir) == false) System.IO.Directory.CreateDirectory(subdir);
            return subdir;
        }
        public void ClearFolder(string folder)
        {
            foreach (string subfolder in System.IO.Directory.GetDirectories(folder))
            {
                ClearFolder(subfolder);
                System.IO.Directory.Delete(subfolder);
            }
            foreach (string file in System.IO.Directory.GetFiles(folder))
            {
                System.IO.File.Delete(file);
            }
        }
        public void DeleteFolder(string folder)
        {
            ClearFolder(folder);
            System.IO.Directory.Delete(folder);
        }
        public string Outputdir
        {
            get
            {
                return outputdir;
            }
        }
        public DirectoryStructure(string outputdir)
        {
            this.outputdir = outputdir;
            if (System.IO.Directory.Exists(outputdir) == false) System.IO.Directory.CreateDirectory(outputdir);
            else ClearFolder(outputdir);
        }
    }
}
